<?php
namespace app\index\controller;

use think\captcha\Captcha;
use think\Controller;

class Index extends MyController
{
    public function index()
    {
        //文章列表
        $current = input('page',1);
        $limit = 10;
        $start = ($current-1)*$limit;
        $info = db('information')
            ->alias('i')
            ->leftJoin('info_category c','i.cat_id=c.cat_id')
            ->order('info_id','DESC')
            ->limit($start,$limit)
            ->paginate($limit);


        //会员动态
        $dynamic = db('dynamic')
            ->alias('d')
            ->field('dy_id,content,pubtime,u.username,u.face')
            ->leftJoin('user u','d.u_id=u.u_id')
            ->order('dy_id','DESC')
            ->limit(15)
            ->select();

        //广告图
        $banner = db('banner')->select();

        //侧边栏
        $right = db('information')->where('cat_id',3)->select();


        $this->assign([
            'info'=>$info,
            'dynamic'=>$dynamic,
            'banner' => $banner,
            'right' => $right
        ]);
        return view();
    }
}
